package com.ijiuchuang.jc_localization.rx;

import com.ijiuchuang.jc_localization.bean.event.BeaconTagData;

import rx.functions.Func1;

/**
 * Created by Veev on 2016/6/15
 *
 * @link 384506557@qq.com
 */
public class MapOnBeaconTagDataToNumber implements Func1<BeaconTagData, Integer> {

    private static volatile MapOnBeaconTagDataToNumber sInst = null;

    public static MapOnBeaconTagDataToNumber getInstance() {
        MapOnBeaconTagDataToNumber inst = sInst;
        if (inst == null) {
            synchronized (MapOnBeaconTagDataToNumber.class) {
                inst = sInst;
                if (inst == null) {
                    inst = new MapOnBeaconTagDataToNumber();
                    sInst = inst;
                }
            }
        }
        return inst;
    }

    private MapOnBeaconTagDataToNumber() {
    }

    @Override
    public Integer call(BeaconTagData beaconTagData) {

        int nodeNumber = 1;

        switch (beaconTagData.beaconUuid) {
            case "123456789004":
                nodeNumber = 5;
                break;
            case "123456789003":
                nodeNumber = 4;
                break;
            case "123456789002":
                nodeNumber = 3;
                break;
            case "123456789001":
                nodeNumber = 2;
                break;
            case "123456789000":
                nodeNumber = 1;
                break;
            default:
                nodeNumber = 0;
                break;
        }
        return nodeNumber;
    }
}
